<template>
  <div>
    <Myheader title="我的----TabBar案例" bg="red" color="black"></Myheader>
    <div class="main">
      <keep-alive>
        <component :is="comon"> </component>
      </keep-alive>
    </div>
    <MyTabBar :tabs="tabList" @tabFn="changeTab"></MyTabBar>
  </div>
</template>

<script>
import Myheader from "./components/Myheader";
import MyTabBar from "./components/MyTabBar";
import UserInfo from "./view/UserInfo";
import MyGoodsList from "./view/MyGoodList";
import MyGoodsSearch from "./view/MyGoodsSearch";

export default {
  components: {
    Myheader,
    MyTabBar,
    UserInfo,
    MyGoodsList,
    MyGoodsSearch,
  },
  data() {
    return {
      comon: "MyGoodsList", //初始化显示商品列表
      tabList: [
        {
          iconText: "icon-shangpinliebiao",
          text: "商品列表",
          componentName: "MyGoodsList",
        },
        {
          iconText: "icon-sousuo",
          text: "商品搜索",
          componentName: "MyGoodsSearch",
        },
        {
          iconText: "icon-user",
          text: "我的信息",
          componentName: "UserInfo",
        },
      ],
    };
  },
  methods: {
    changeTab(name) {
      this.comon = name;
    },
  },
};
</script>

<style>
.main {
  padding: 45px 0 50px 0;
}
</style>